#!/bin/sh

: ${runtime:=600}
: ${sub_group_number:=8}
: ${group_file_number:=8}

jobfile=fio_jbod_${disk_description}_${rw}_${ioengine}_${fallocate}_${blocksize}
[ "${jobfile#*__}" != "$jobfile" ] && {
	echo "error composing $jobfile: missing options" >&2
	exit 1
}

cat > $jobfile <<EOF
[global]
runtime=$runtime
rw=$rw
direct=0
ioengine=$ioengine
size=8G
blocksize=$blocksize
numjobs=1
fallocate=$fallocate
overwrite=0
# create_sparse=1 # not supported in upstream fio
invalidate=0
file_service_type=random:36

EOF

for mnt in $mount_points
do
	sdx=$(basename $mnt)
	for sgx in $(seq $sub_group_number)
	do
		echo "[job_${sdx}_sub$sgx]"
		echo "startdelay=0"
		line="filename="
		for fn in $(seq $group_file_number)
		do
			line="${line}$mnt/$fn:"
		done
		echo $line
	done >> $jobfile
done
